<?php
/**
 *
 * Author:苏光盼
 * Date:2020/5/27 上午12:00
 * Class:Redis.php
 * Web:https://zoodt.com
 * Project:在线工具
 *
 *
 *
 */

namespace App\ServerInit;
use EasySwoole\RedisPool\Redis as PoolRedis;
use EasySwoole\Redis\Config\RedisConfig;
use EasySwoole\RedisPool\RedisPool;
class Redis
{
    private static  $redisConfig;

    public static function init() :void
    {
        self::$redisConfig = new RedisConfig([
            'host'   => '127.0.0.1',
            'port'   => 6379,
            'auth'   => null,
            'serialize' => RedisConfig::SERIALIZE_PHP
        ]);
        $redisPool = PoolRedis::getInstance()->register('redis',self::$redisConfig );
        $redisPool->setMinObjectNum(5);
        $redisPool->setMaxObjectNum(20);

    }

    public static function getRedisConfig()
    {
        return self::$redisConfig;
    }


    public static function getRedisPool() : RedisPool
    {
        return new RedisPool(self::$redisConfig);
    }

}